package cn.wange;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class OutCalendar {
    public static void main(String[] args) throws ParseException {
        Calendar cc = Calendar.getInstance();
        long timeInMillis = cc.getTimeInMillis();
        String time = "2023-10-11 19:18:00";
        String content = "你好";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parsed = simpleDateFormat.parse(time);
        long timeDifference = System.currentTimeMillis() - parsed.getTime();
        if (timeDifference / 1000 / 60 < 1)
            System.out.printf("刚刚：%s", content);
        else if (timeDifference / 1000 / 60 >= 1 && timeDifference / 1000 / 60 < 60) {
            System.out.printf("%d分钟前：%s", timeDifference / 1000 / 60, content);
        } else if (timeDifference / 1000 / 60 / 60 >= 1 && timeDifference / 1000 / 60 / 60 < 24) {
            System.out.printf("%d小时前：%s", timeDifference / 1000 / 60 / 60, content);

        } else if (timeDifference / 1000 / 60 / 60 / 24 >= 1 && timeDifference / 1000 / 60 / 60 / 24 < 7) {
            System.out.printf("%d天前：%s", timeDifference / 1000 / 60 / 60 / 24, content);

        } else {
            System.out.printf("%tF %<tT：%s", parsed, content);
        }
    }
}
